package com.tywj.panda.customer.usercenter.center

import com.tywj.panda.customer.common.view.dialog.BottomDialog
import com.tywj.lib.core.common.extension.onClick
import com.tywj.panda.customer.usercenter.R
import kotlinx.android.synthetic.main.user_dialog_photo_choose.*

/**
 * <pre>
 *     author : June Yang
 *     time   : 2020/6/2
 *     desc   : 图片选择弹窗
 *     version: 2.0.0
 * </pre>
 */
class PhotoChooseDialog : BottomDialog() {

    companion object {
        const val TYPE_TAKE_PHONE = 1
        const val TYPE_FROM_ALBUM = 2
        const val TAG = "PhotoChooseDialog"
    }


    private var onChoseListener: ((Int) -> Unit)? = null

    override fun getLayoutID(): Int = R.layout.user_dialog_photo_choose

    override fun initListener() {
        super.initListener()

        flTakePhone.onClick {
            onChoseListener?.invoke(TYPE_TAKE_PHONE)
            dismissDialog()
        }

        flFromAlbum.onClick {
            onChoseListener?.invoke(TYPE_FROM_ALBUM)
            dismissDialog()
        }

        flNegative.onClick {
            dismissDialog()
        }
    }

    fun setonChoseListener(listener: (index: Int) -> Unit) {
        onChoseListener = listener
    }
}